<script type="text/javascript" language="javascript">
	(function($)
		{
			/*whatever jQuery stuff*/
			$(function()
				{
					$("#Form").validate(
						{
							ignore: "",
							rules:
							{
								fashion_category: "required",
								fashion_name: "required",
								fashion_description:"required",
								fashion_tag: "required"
							},
							showErrors: function(errorMap, errorList)
							{
								var messages='';
								for (var i = 0; i < errorList.length; i++)
								{
									messages += '- '+errorList[i].message+'\n';
								}
								if(messages) alert("<?php echo lang('requirement');?>: \n"+"¯¯¯¯¯¯¯¯¯¯ \n"+ messages);
								//this.defaultShowErrors();
							} ,
							submitHandler: function(e)
							{
								$('.ajax-loading',e).css('visibility','visible');
								if(queueSize > 0)
								{
									$('#file_upload').uploadifyUpload();
								} else
								{
									success_file = true;
								}
								var interval = setInterval(function()
									{
										if (success_file)
										{
											clearInterval(interval);
											//Send Form
											document.forms["Form"].submit();
										}
									}, 100);
							},
							onfocusout: false,
							onkeyup: false,
							onclick: false,
							messages:
							{
								fashion_category: "<?php echo lang('fashion_category');?>",
								fashion_name: "<?php echo lang('fashion_subject');?>",
								fashion_description: "<?php echo lang('fashion_description');?>",		
								fashion_tag: "<?php echo lang('fashion_tag');?>"
							}
						});

					/*Images Upload*/
					var queueSize = 0;
					var imgname= new Array();
					var success_file = false;
					$('#file_upload').uploadify(
						{
                			'uploader'  : '<?php echo base_url();?>uploadify.swf',				
                			'script'    : '<?php echo base_url();?>uploadify.php',
							'cancelImg' : '<?php echo js_asset_url("uploadify/cancel.png"); ?>',
							'folder'    : "<?php echo substr($this->temp_folder,0,-1);?>",
                			'fileExt'   : '*.jpg;*.JPG;*.gif;*.GIF;*.png;*.PNG',
							'fileDesc'  : 'All Files',
							'scriptAccess' : 'always',
							'auto'      : false,
							'multi'     : true,
							'onComplete' : function(event, ID, fileObj, response, data)
							{
								imgname.push(response);
							},
							'onAllComplete' : function(event,data)
							{
								$('<input>').attr(
									{
										type: 'hidden',
										id: 'uploadify_store',
										name: 'uploadify_store',
										value: imgname
									}).appendTo('Form');
								//document.forms["Form"].submit();
								success_file=true;
							},
							'onSelectOnce' : function (event,data)
							{
								queueSize = data.fileCount;
							},
							'onCancel' : function (event,ID,fileObj,data)
							{
								queueSize = data.fileCount;
							}
						});	
					//ColorBox Iframe
					$('.search_tools').colorbox({iframe:true, innerWidth:300, innerHeight:600, right:0, opacity:0.4});
					//ColorBox Image
					$('a[rel="fashion"]').colorbox();					
					//Drag && Drop
					$( ".listImages" ).sortable(
						{
							connectWith: "li",
							cursor: 'move',
							handle: 'img',
							placeholder: 'placeholder',
							forcePlaceholderSize: true,
							opacity: 0.4,
							update: function(event, ui)
							{
								//do process
								var data = $(this).sortable('serialize');
								$.ajax(
									{
										type:'post',
										url:web_path+'fashion/content_management/ajax_update_image',
										data:data
									});
							}
						}).disableSelection();
						
					//DateTime Picker
					$('.datetime').datetimepicker({
						dateFormat:'dd/mm/yy',
						timeFormat:'hh:mm',
						separator:' ',
						changeMonth : true,
						changeYear : true,
						yearRange: '-100y:c+nn',
						maxDate: '-1d',
						showHour: true,		
						showMinute: true,
						showTime: true		
					});							
				});
		})(jQuery);	
</script>
<div class="wrap">
	<div id="icon-index" class="icon32">
		<br />
	</div>
	<h2>
		<?php echo ucwords(str_replace('_',' ',$this->uri->segment(1)));?> &raquo; <?php echo ucwords(str_replace('_',' ',$this->uri->segment(2)));?> &raquo; <?php echo lang($this->uri->segment(3));?>
	</h2>
</div>
<div id="wpbody-content">
	<div class="metabox-holder" id="dashboard-widgets">
		<div class="tablenav top">
			<div class="alignleft">
				<input type="button" value="<?php echo lang('button_back');?>" class="button-primary" onclick="javascript:history.go(-1);"/>
			</div>
		</div>
		<div class="inside">
			<form id="Form" method="post" action="" name="Form">
				<table border="0" cellspacing="0" cellpadding="0" class="form-table">
					<tbody>
						<tr>
							<th scope="row">
								<?php echo lang('is_publish');?>
							</th>
							<td>
								<input type="radio" name="is_publish" value="1" <?php echo ($dataResult->is_publish == '1' ? 'checked="checked"':'');?>/> <?php echo lang('yes');?>
								<input type="radio" name="is_publish" value="0" <?php echo ($dataResult->is_publish == '0' ? 'checked="checked"':'');?>/> <?php echo lang('no');?>
							</td>
						</tr>
						<tr>
							<th scope="row">
								<?php echo lang('fashion_publish_date');?>
							</th>
							<td>
								<input type="text" name="fashion_publish_date" id="fashion_publish_date" class="medium-text datetime" value="<?php echo convertDatetimeToString($dataResult->fashion_publish_date);?>" readonly="readonly"/>
							</td>
						</tr>							
						<tr>
							<th scope="row">
								<?php echo lang('fashion_category');?>
							</th>
							<td>
								<select name="fashion_category" id="fashion_category">
									<option value=""><?php echo lang('select_option');?></option>
									<option <?php echo ($dataResult->fashion_category=="Fashion Magazine" ? 'selected="selected"':'');?>>Fashion Magazine</option>
									<option <?php echo ($dataResult->fashion_category=="Fashion Women" ? 'selected="selected"':'');?>>Fashion Women</option>
									<option <?php echo ($dataResult->fashion_category=="Fashion Men" ? 'selected="selected"':'');?>>Fashion Men</option>
									<option <?php echo ($dataResult->fashion_category=="Event" ? 'selected="selected"':'');?>>Event</option>
								</select>
							</td>
						</tr>
						<tr>
							<th scope="row">
								<?php echo lang('news_main_hilight');?>
							</th>
							<td>
								<input type="radio" name="is_main_hilight" value="1" <?php echo ($dataResult->is_main_hilight == '1' ? 'checked="checked"':'');?>/> <?php echo lang('yes');?>
								<input type="radio" name="is_main_hilight" value="0" <?php echo ($dataResult->is_main_hilight == '0' ? 'checked="checked"':'');?>/> <?php echo lang('no');?>
							</td>
						</tr>
						<tr>
							<th scope="row">
								<?php echo lang('news_type_hilight');?>
							</th>
							<td>
								<input type="radio" name="is_type_hilight" value="1" <?php echo ($dataResult->is_type_hilight == '1' ? 'checked="checked"':'');?>/> <?php echo lang('yes');?>
								<input type="radio" name="is_type_hilight" value="0" <?php echo ($dataResult->is_type_hilight == '0' ? 'checked="checked"':'');?>/> <?php echo lang('no');?>
							</td>
						</tr>																												
						<tr>
							<th scope="row">
								<?php echo lang('fashion_name');?>
							</th>
							<td>
								<input type="text" name="fashion_name" id="fashion_name" class="regular-text" value="<?php echo htmlspecialchars($dataResult->fashion_name, ENT_QUOTES, 'UTF-8');?>"/>
							</td>
						</tr>
						<tr>
							<th scope="row"><?php echo lang('fashion_brief');?></th>
							<td>
								<textarea name="fashion_brief" id="fashion_brief" rows="5" class="regular-text"><?php echo $dataResult->fashion_brief;?></textarea>
							</td>
						</tr>						
						<tr>
							<th scope="row">
								<?php echo lang('fashion_description');?>
							</th>
							<td><?php echo display_ckeditor('fashion_description',''.$dataResult->fashion_description.'',array('toolbar' => 'Medium','skin' => 'v2','width' => '550px','height' => '200px'),false); ?></td>
						</tr>
						<tr>
							<th scope="row"><?php echo lang('fashion_tag');?></th>
							<td><input type="text" name="fashion_tag" id="fashion_tag" class="regular-text" value="<?php echo htmlspecialchars($dataResult->fashion_tag, ENT_QUOTES, 'UTF-8');?>"/></td>
						</tr>												
						<tr>
							<th scope="row">
								<?php echo lang('fashion_image');?>
							</th>
							<td>
								<?php
								if(!empty($dataFashionImage)):?>
								<ul class="listImages">
									<?php
									foreach($dataFashionImage as $value):?>
									<li id="fashion_image_id_<?php echo $value->fashion_image_id;?>">
										<div>
											<a href="<?php echo image_asset_url('../uploads/fashion/images/watermark/'.$value->fashion_file_name.'.'.$value->fashion_file_ext);?>" rel="fashion">
												<?php echo image_asset('../uploads/fashion/images/120x120/'.$value->fashion_file_name.'.'.$value->fashion_file_ext,'',array('width' => 120,'height'=> 120));?>
											</a>
										</div>
										<a href="javascript:void(0);" title="<?php echo image_asset_url('../uploads/fashion/images/watermark/'.$value->fashion_file_name.'.'.$value->fashion_file_ext);?>" onmouseOver="javascript:toClipboard(this)" class="tools wishlist"></a>										
										<a href="<?php echo base_url();?>fashion/content_management/ajax_delete_image/<?php echo $value->fashion_image_id;?>" class="tools delete deleteImage"></a>
									</li>
									<?php endforeach;?>
								</ul>
								<?php endif;?>
								<input type="file" name="file_upload" id="file_upload"/>&nbsp;&nbsp;<input type="checkbox" name="image_watermark_disable" id="image_watermark_disable"/> <?php echo lang('image_watermark_disable');?>
							</td>
						</tr>
						<tr>
							<th scope="row">
								<?php echo lang('update_date');?>
							</th>
							<td class="describe"><?php echo $dataResult->update_date;?></td>
						</tr>						
						<tr>
							<th scope="row">
								&nbsp;
							</th>
							<td>
								<p class="submit">
									<input type="submit" value="<?php echo lang('button_edit');?>" class="button-primary" />&nbsp;<img alt="" class="ajax-loading" src="<?php echo css_asset_url('images/wpspin_light.gif'); ?>" />
								</p>
							</td>
						</tr>
					</tbody>
				</table>
				<div class="tablenav bottom">
				</div>
			</form>
		</div><!-- wpbody inside -->
	</div><!-- wpcontent -->
</div><!-- wpbody-content -->